package com.crystal.jcms.ui;

import com.crystal.constant.Constant;
import com.crystal.jcms.shpz.R;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

/**
 *	按钮控件
 *
 * 	@author Lean  @date:2014-8-4  
 */
public class ImageText extends LinearLayout{
	
	private ImageView mImageView;
	private TextView mTextiew;
//	private static final int DEFAULT_SIZE_WIDTH=64;
//	private static final int DEFAULT_SIZE_HEIGHT=30;
	//private static final float TEXT_SIZE=14.0f;
	
//	private int mTextDefaulColor=0xff929292;
//	private int mTextSelectedColor=0xff007aff;
	
	private int mTextDefaulColor=0xffffffff;
	private int mTextSelectedColor=0xffffffff;
	
	public ImageText(Context context, AttributeSet attrs) {
		super(context, attrs);
		LayoutInflater.from(context).inflate(R.layout.layout_image_text, this,true);
		mImageView=(ImageView) findViewById(R.id.iv_imgae_text);
		mTextiew=(TextView) findViewById(R.id.tv_imgae_text);
	}
	

	public void setText(String s)
	{
		if (mTextiew!=null) {
			mTextiew.setText(s);
			setTextColor(mTextDefaulColor);
			//mTextiew.setTextSize(TEXT_SIZE);
			//setTextSize(DEFAULT_SIZE_WIDTH,DEFAULT_SIZE_HEIGHT);
		}
	}

	public void setTextColor(int color) {
		mTextiew.setTextColor(color);
	}
	
	private void setTextSize(int defaultSizeWidth, int defaultSizeHeight) {
		LayoutParams params=(LayoutParams) mTextiew.getLayoutParams();
		params.width=defaultSizeWidth;
		params.height=defaultSizeHeight;
		mTextiew.setLayoutParams(params);
	}

	public void setImage(int resId)
	{
		if (mImageView!=null) {
			mImageView.setImageResource(resId);
		}
	}
	
//	public void setChecked(int itemId)
//	{
//		if (mTextiew!=null) {
//			setTextColor(mTextSelectedColor);
//		}
//		switch (itemId) {
//		case Constant.SIGN_FRAGMENT_APPS:
//			mImageView.setImageResource(R.drawable.menu);
//			break;
//		case Constant.SIGN_FRAGMENT_SET:
//			mImageView.setImageResource(R.drawable.more);
//			break;
//		}
//	}
	
	
}
